package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.TCustomer;
import com.ruoyi.system.service.TCustomerService;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (TCustomer)表控制层
 *
 * @author makejava
 * @since 2025-01-02 20:11:52
 */
@RestController
@RequestMapping("tCustomer")
public class TCustomerController extends BaseController     {
    /**
     * 服务对象
     */
    @Resource
    private TCustomerService tCustomerService;

    /**
     * 分页查询
     *
     * @param tCustomer 筛选条件
     * @return 查询结果
     */
    @GetMapping
    public TableDataInfo queryByPage(TCustomer tCustomer) {
        startPage();
        return getDataTable(this.tCustomerService.queryByPage(tCustomer));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<TCustomer> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.tCustomerService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param tCustomer 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<TCustomer> add(TCustomer tCustomer) {
        return ResponseEntity.ok(this.tCustomerService.insert(tCustomer));
    }

    /**
     * 编辑数据
     *
     * @param tCustomer 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<TCustomer> edit(TCustomer tCustomer) {
        return ResponseEntity.ok(this.tCustomerService.update(tCustomer));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.tCustomerService.deleteById(id));
    }

}

